<%--
  Created by IntelliJ IDEA.
  User: zhangbo
  Date: 2021/11/7
  Time: 21:51
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <script src="https://cdn.bootcss.com/jquery/3.1.1/jquery.js"></script>

    <script type="text/javascript">
        window.onload = function () {
            $("#btn").click(function () {
                $.post({
                    url: "${pageContext.request.contextPath}/a2",
                    success: function (data) {
                        var ht = "";

                        for (let i = 0; i < data.length; i++) {
                            ht += "<tr>" +
                                "<td>" + data[i].name + "</td>" +
                                "<td>" + data[i].sex + "</td>" +
                                "<td>" + data[i].age + "</td>" +
                                "</tr>"
                        }

                        $("#content").html(ht);
                    }
                })
            });

        }

    </script>
</head>
<body>
<input type="button" value="加载数据" id="btn">
<table>
    <tr>
        <th>姓名</th>
        <th>年龄</th>
        <th>性别</th>
    </tr>
    <tbody id="content">
    </tbody>
</table>

</body>
</html>
